<include file="../header" />
<body class="J_scroll_fixed">
<style type="text/css">
    .btn,.btn-danger,.btn-info,.btn-success,.btn-warning{
        width: 80px;
        /*height: 18px;*/
        padding: 2px 0px 2px 0px;
        margin: 1px 0px 1px 0px;
    }
    select{
        width: auto
    }
</style>
<script type="text/javascript">
    $(function() {

        $("input[name=checkAll]").click(function() {
            var checkboxs = $("input.checkItem");
            if($("input[name=checkAll]").is(':checked')) {
                for(var i = 0 ;i<checkboxs.length;i++) {
                    checkboxs[i].checked = true;
                }
            }else{
                for(var i = 0 ;i<checkboxs.length;i++) {
                    checkboxs[i].checked = false;
                }
            }
        });

        $("a[name=downloadExcel]").click(function() {
            var checkboxs = $("input.checkItem");
            var id = "";
            for (var i = 0; i < checkboxs.length; i++) {
                if(checkboxs[i].checked == true){
                    if(id != ""){
                        id += ",";
                    }
                    id += checkboxs[i].name;
                }
            }
            if(id == ""){
                alert("未选择单据");
                $("input[name=checkAll]").focus();
                return false;
            }
            var agent = $(".agent").val();
            if(agent == 0 ){
                var url = "/admin/FinishedOrder/getTable?id=" + id + "&type=reporting_finished_order";
            }else{
                var url = "/admin/FinishedOrder/getTable?agent=" + agent + "&id=" + id + "&type=reporting_finished_order";
            }
            window.location.href = url;
        });

        $("a[name=downloadExcel2]").click(function() {
            var checkboxs = $("input.checkItem");
            var id = "";
            for (var i = 0; i < checkboxs.length; i++) {
                if(checkboxs[i].checked == true){
                    if(id != ""){
                        id += ",";
                    }
                    id += checkboxs[i].name;
                }
            }
            if(id == ""){
                alert("未选择单据");
                $("input[name=checkAll]").focus();
                return false;
            }
            var agent = $(".agent").val();
            if(agent == 0 ){
                var url = "/admin/FinishedOrder/getTable?id=" + id + "&type=reporting_finished_2_order";
            }else{
                var url = "/admin/FinishedOrder/getTable?agent=" + agent + "&id=" + id + "&type=reporting_finished_2_order";
            }
            window.location.href = url;
        });
    });
</script>
<php>$imgVersion = "2020101002";</php>
<form class="well form-search" method="post" style="float:left;width:100%;margin-bottom: 0px; padding: 5px 10px 5px 10px;" action="{:U('finishedOrder/index')}">
    <div class="search_type cc mb10">
        <div class="mb10">
        <span class="mr20">
            状态：{:getEnumSelectWidget($statusEnum, "fo#status", $status, 1)}
            &nbsp;
            业务员：
            <select name="fo#employee_id-eq">
                {:getCommonSelectOptionHtml($employee_id, "Admin", "employee_id", "admin_name", null, $user['enterprise_code'], 1)}
            </select>
            &nbsp;订单编号：<input type="text" name="fo#finished_order_no-like" value="{$finished_order_no}" style="width: 150px"/>
            用户名称：<input type="text" name="fo#customer_name-like" value="{$customer_name}" style="width: 150px"/>
            产品名称：<input type="text" name="fp#name-like" value="{$name}" style="width: 150px"/>
            患者：<input type="text" name="fo#patient_name-like" value="{$patient_name}" style="width: 150px"/>
            <br>
            渠道：
            <!--<select name="fo#agent_name-eq" class="agent">-->
                    <!--{:getCommonSelectOptionHtml($agent_name, "Agent", "agent_name", "agent_name", null, $user['enterprise_code'], 1)}-->
            <!--</select>-->
            <select name="fo#agent_name-eq" class="agent">
                        {:getAgentSelectOptionHtmlList($agent_name, "Agent", "agent_name", "agent_name", null, $user['enterprise_code'], 1, null, -1)}
                </select>
            付款方式：
            <select name="fo#payment_type-eq">
                <option value=""></option>
                <option value="现结">现结</option>
                <option value="半月结">半月结</option>
                <option value="月结">月结</option>
            </select>
            下单开始时间：<input type="text" value="{$begin_time}" style="width: 100px" class="date J_date" name="fo#create_time-egt" />
            下单截止时间：<input type="text" value="{$end_time}" style="width: 100px" class="date J_date" name="fo#create_time-elt" />
            <button class="btn btn-primary" type="submit">搜索</button>
            <a class="btn" href="{:U('finishedOrder/index')}">重置</a>
            <if condition="$isAdmin eq 'TRUE'">
                类型：
                <select name="fp#class_id-eq">
                         {:getCommonSelectOptionHtml($class_id, "Class", "class_id", "class_name", null, $user['enterprise_code'], 1)}
                 </select>
                渠道：
                <select name="fo#agent_name-eq" class="agent">
                        {:getAgentSelectOptionHtmlList($agent_name, "Agent", "agent_name", "agent_name", null, $user['enterprise_code'], 1, null, 1)}
                </select>
            </if>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

            <br><br>
            每页显示：
            <select name="pageSize" style="color: #1dccaa">
                <option value=''></option>
                <php>$selected=($pageSize == 20)?"selected":"";</php>
                <option value='20' {$selected}>20 条</option>
                <php>$selected=($pageSize == 50)?"selected":"";</php>
                <option value='50' {$selected}>50 条</option>
                <php>$selected=($pageSize == 100)?"selected":"";</php>
                <option value='100' {$selected}>100 条</option>
                <php>$selected=($pageSize == -1)?"selected":"";</php>
                <option value='-1' {$selected}>全部</option>
            </select>

            &nbsp;&nbsp;&nbsp;
            <a style="font-weight: bold;color: #1dccaa">
                【查询结果】
            </a>
            <a style="color: #1dccaa">
                条数：{$totalCount}，
            </a>
            <a style="color: #45a1de">
                成品总数：{$totalNumber}，
            </a>
            <a style="color: #ed7667">
                总金额：{$totalPrice} 元
            </a>
        </span>
        </div>
    </div>
</form>

<div class="wrap J_check_wrap" style="padding: 2px 5px 0px 5px; overflow-x:auto;">
    <ul class="nav nav-tabs">
        <li class="active"><a>相关信息</a></li>
        <li><a name="downloadExcel" style="cursor: pointer;">下载选中报表</a></li>
        <li><a name="downloadExcel2" style="cursor: pointer;color: #de7d74">下载选中报表(CP方式)</a></li>
    </ul>
    <table class="table table-hover table-bordered">
        <thead>
        <tr>
            <th style="min-width: 10px; width: 10px"><input type="checkbox" name="checkAll"></th>
            <th style="min-width: 50px" width="150px">订单信息</th>
            <th width="250px">产品信息</th>
            <th style="min-width: 50px" width="100px">渠道/付款方式</th>
            <th>需要发票</th>
            <th>收件信息</th>
            <th width="150px">备注</th>
            <th style="min-width: 165px" width="165px">状态</th>
            <th style="min-width: 160px" width="160px">操作</th>
        </tr>
        </thead>
        <tbody>
        <foreach name="orderList" item="vo">
            <tr>
                <php>
                    $checkName = $vo["finished_order_id"];
                </php>
                <td><input type="checkbox" class="checkItem" name="{$checkName}"></td>
                <td>({$vo.finished_order_id})<a style="color: #45a1de">{$vo.admin_name}</a><br>{$vo.finished_order_no}<br>{$vo.create_time}</td>
                <td><a style="font-weight: bold">{$vo.name}</a><br>数量：<a style="color: #ed7667">{$vo.number}</a> 件， 规格：<a>{$vo.size}</a><br>单价：<a style="color: #ed7667">{$vo.sale_price}</a>， 总计：<a style="color: #ed7667">{$vo.total_price}</a>&nbsp;元<br>患者：<a style="color: #45A1DE">{$vo.patient_name}</a></td>
                <td><a>{$vo.agent_name}</a><br/><a style="color: #ffa451"> {$vo.payment_type}</a></td>
                <td>
                    {:getEnumString($defaultEnum, $vo['need_invoice'])}
                    <if condition="$vo['need_invoice'] eq $defaultEnum['YES']">
                        : <a style="color: #45a1de">{$vo.invoice_name}</a><br>税号 : <a style="color: #45a1de">{$vo.invoice_number}</a>
                    </if>
                    <if condition="$vo['need_invoice'] neq $defaultEnum['NO']">
                        <br>明细 : <a style="color: #45a1de">{$vo.invoice_detail}</a>
                    </if>
                </td>
                <td>
                    <a style="color: #ed7667">【{$vo.delivery_type}】</a> {$vo.receive_name}，{$vo.receive_contact}
                    <if condition="$vo['delivery_type'] neq '自提'">
                        <br>地址：{$vo.receive_address}
                    </if>
                </td>
                <td><a style="color: #ed7667">{$vo.note}</a></td>
                <td>
                    <php>
                        $statusArr = array();
                        $statusArr["-1"] = "处理中";
                        $statusArr["1"] = "已出库";
                        $statusArr[$vo["status"]] .= "亮";
                    </php>
                    <div style="padding: 0px 2px 0px 2px;">
                        <img style="width: 65px;height: auto" src="/Template/images/{$statusArr.-1}.png?v={$imgVersion}"/>
                        <img style="width: 20px;height: auto" src="/Template/images/arrow.png"/>
                        <img style="width: 65px;height: auto" src="/Template/images/{$statusArr.1}.png?v={$imgVersion}"/>
                    </div>
                </td>
                <td>
                    <php>
                        $outstoreStatus = -1;
                        $role = explode(',',$user["role"]);
                        if(in_role($role,"1,3,4,8")){
                        $outstoreStatus = 1;
                        }
                    </php>
                    <if condition="$vo['status'] eq $statusEnum['WAITING_PROCESS'] && $outstoreStatus eq '1'">
                        <a class="btn btn-info" href='{:U("finishedOrder/endDelivery",array("id"=>$vo["finished_order_id"]))}'>确认出库</a>
                        <a class="btn btn-danger" onclick="if(confirm('确认关闭此订单么?')==false)return false;" href='{:U("finishedOrder/closeOrder",array("id"=>$vo["finished_order_id"]))}' >关闭订单</a>
                    </if>
                    <if condition="$vo['status'] eq $statusEnum['END_DELIVERY']">
                        出库人：<a style="color: #45a1de">{$vo.delivery_name}</a><br>{$vo.outstock_time}
                        <br>{$vo.express_company}  {$vo.delivery_number}
                    </if>
                    <br>
                    <if condition="$vo['approve_id'] gt 0 && $vo['status'] neq '-2'">
                        <a style="color: #1dccaa">【审批通过】</a>
                        <a style="color: #45a1de">{$vo.approve_name}</a>
                    </if>
                    <if condition="$vo['approve_id'] gt 0 && $vo['status'] eq '-2'">
                        <a style="color: #ed7667">【审批未通过】</a>
                        <a style="color: #45a1de">{$vo.approve_name}</a>
                    </if>
                </td>
            </tr>
        </foreach>
        </tbody>
    </table>
    <div class="pagination">{$page}</div>
</div>
<script src="__ROOT__/statics/js/common.js"></script>
</body>
</html>